#include<unistd.h>
#include<signal.h>
#include<iostream>
using namespace std;

void handler(int signo)
{
    cout << "The signal is " << signo << endl;
    sleep(1);
}
int main()
{
    sigset_t set,old;
    sigemptyset(&set);
    sigemptyset(&old);

    sigaddset(&set,2);
    sigaddset(&set,40);

    sigprocmask(SIG_BLOCK,&set,&old);

    signal(2,handler);
    signal(40,handler);

    cout << "send 2 signal" << endl;
    sleep(1);
    int cnt = 5;
    while(cnt > 0)
    {
        kill(getpid(),2);
        cout << cnt << endl;
        cnt--;
    }

    cout << "send 40 signal" << endl;
    sleep(1);
    cnt = 5;
    while(cnt > 0)
    {
        kill(getpid(),40);
        cout << cnt << endl;
        cnt--;
    }
    return 0;
}
